package edu.szu.huhanpeng.doodlingFight.controller.dataController.exchange 
{
	import edu.szu.huhanpeng.doodlingFight.globalConst.GlobalConst;
	import edu.szu.huhanpeng.doodlingFight.interfaces.IChessData;
	import edu.szu.huhanpeng.doodlingFight.interfaces.ISquareData;
	import edu.szu.huhanpeng.doodlingFight.model.ChessBoardProxy;
	import edu.szu.huhanpeng.doodlingFight.model.ChessGroupProxy;
	import org.puremvc.as3.interfaces.ICommand;
	import org.puremvc.as3.interfaces.INotification;
	import org.puremvc.as3.interfaces.INotifier;
	import org.puremvc.as3.patterns.command.SimpleCommand;
	
	/**
	 * ...
	 * @author Huhanpeng
	 */
	public class ChangeTwoChessDc extends SimpleCommand implements ICommand, INotifier 
	{
		/**
		* noteName:	EXCHANGE
		* noteBody:	Vector.<IChessData>,元素为交换的两个棋子data
		* noteType:	
		*/
		override public function execute(note:INotification):void 
		{
			var body: Vector.<IChessData> = note.getBody() as Vector.<IChessData> ;
			
			if (body == null) 
			{
				if (GlobalConst.setting.DEBUG) 
				{
					throw new Error("body类型出错");
				}
				return;
			}
						
			var squareA:ISquareData = body[0].square;
			var squareB:ISquareData = body[1].square;
			squareB.placeChess(body[0]);
			squareA.placeChess(body[1]);
			
			//把chessGroup里的prepare 转变为 done
			var chessGroup:ChessGroupProxy = facade.retrieveProxy( ChessGroupProxy.NAME ) as ChessGroupProxy;
			chessGroup.getPrepareDone( body[0], body[1] );
			
		}
		
	}

}